﻿using Common.Communal;
using ERP.Domain.System;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Api.Read.Applications.Commands.Organizes;
using System.Api.Read.Applications.Commands.Posts;
using System.Api.Read.Applications.Commands.Users;
using System.DTO;

namespace System.Api.Read.Controllers
{
    /// <summary>
    /// 组织机构
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class OrganizeController : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator mediator;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator">中介者</param>
        public OrganizeController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 组织机构分页查询
        /// </summary>
        /// <param name="command">命令</param>
        /// <returns>返回结果</returns>
        [HttpGet]
        public Task<ApiResult<List<OrganizeDTO>>> GetOrganize([FromQuery] OrganizeQueryCommand command)
        {
            return mediator.Send(command);
        }
        /// <summary>
        /// 获取组织类型
        /// </summary>
        /// <param name="command">命令</param>
        /// <returns>返回结果</returns>
        [HttpGet]
        public Task<ApiResult<List<OrganizeType>>> GetOrganizeType()
        {
            OrganizeTypeQueryCommand command = new OrganizeTypeQueryCommand();
            return mediator.Send(command);
        }
        /// <summary>
        /// 获取用户
        /// </summary>
        /// <returns>返回结果</returns>
        [HttpGet]
        public Task<ApiResult<List<User>>> GetUser()
        {
            UserQueryCommand command = new UserQueryCommand();
            return mediator.Send(command);
        }
    }
}
